import { Button } from "antd-mobile";
import React from "react";
import styles from "./index.module.css";
import { EditTime } from "../../store/CitySlice";
import { useSelector, useDispatch } from "react-redux";
import dayjs from "dayjs";
function Index() {
//   const { state } = props;
  const dispatch = useDispatch();
  // console.log(state,"12345678")
  const { date } = useSelector((state) => state.CitySlice);
  const handleClickTime = (num) => {
    const TimeObj = dayjs(date).add(num, "day").format("YYYY-MM-DD");
    dispatch(EditTime({ date: TimeObj }));
  };
  return (
    <div>
      <div className={styles.timeitems}>
        <Button size="mini" shape="rounded" onClick={() => handleClickTime(-1)}>
          前一天
        </Button>
        <span>{date}</span>
        <Button size="mini" shape="rounded" onClick={() => handleClickTime(1)}>
          后一天
        </Button>
      </div>
    </div>
  );
}

export default Index;
